package com.bole.service.impl;

import com.bole.dao.ArticleDao;
import com.bole.pojo.ArticleDo;
import com.bole.service.ArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    private ArticleDao articleDao;

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<ArticleDo> listArticle() {
        return articleDao.findAll();
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Override
    public ArticleDo articleById(Long id) {
        return articleDao.findById(id);
    }

    @Override
    public void saveArticle(ArticleDo articleDo) {
        System.out.println(articleDo.getContent());
        articleDo.setCreateTime(new Date());
        articleDo.setAdminId(1L);
        articleDo.setStatus("0");
        articleDao.save(articleDo);
    }
}
